
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>

#include "glx-utils.h"
#include "Hello_Triangle.h"
#include "esUtil.h"
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>

const int height = 512;
const int width = 512;

void render(ESContext *esContext)
{
  htDraw(esContext);
}

int main(int argc, char *argv[])
{
  Display *display = getDisplay();
  Window window;
  GLXContext glxContext;
  ESContext esContext;
  HTUserData userData;

  createWindowAndGLXContext(width, height, &window, &glxContext);
  showWindow(window);
  glXMakeCurrent(display, window, glxContext);

  esInitContext(&esContext);
  esContext.userData = &userData;
  esContext.width = width;
  esContext.height = height;
  htInit(&esContext);

  while (1) {
    render(&esContext);
    glXSwapBuffers(display, window);
    sleep(1);
  }

  htShutDown(&esContext);

  exit(EXIT_SUCCESS);
}
